#include "Acsvr.h"

Acsvr::Acsvr(){
}

Acsvr::~Acsvr(){
}

int Acsvr::init(){
    return 0;
}

int Acsvr::deInit(){
    return 0;
}

void Acsvr::run(){
    createSocket("127.0.0.0",9999);
    
    while(1){
        int ret = select();
        if(ret){
            ret = accept();
            if(ret){
                std::string recvMsg;
                std::string sendMsg;
                readMsg(recvMsg);
                handleMsg(recvMsg,sendMsg);
                writeMsg(sendMsg);
            }
        }
    }
}


int Acsvr::createSocket(const std::string & ip, int port){
    socket = 1;
    return 0;
}

int Acsvr::accept(){
    return 1;
}

int Acsvr::select(){
    return 1;
}

int Acsvr::readMsg(std::string & recvMsg){
    recvMsg.append("recv msg");
    return 0;
}

int Acsvr::handleMsg(const std::string & recvMsg, std::string & sendMsg){
    sendMsg.append("send msg");
    return 0;
}

int Acsvr::writeMsg(const std::string & sendMsg){
    printf("writeMsg: %s\n",sendMsg.c_str());
    return 0;
}
